///////////////////////////////////////////////////////////////////////
//  CS 3716 (Winter 2012), Assignment #4                       		 //
//  Program File Name: PMovieRec.java                          		 //
//       Student Name: Jonathan Hart-Wall, Adam Murphy         		 //
//					   Yifu Liang, Joshua Dowling			   		 //
//         Login Name: jcwhw1, agm264 , n96yl, n23jdd                //
//              MUN #: 200933455, 200933133, 200565679, 200703684    //
///////////////////////////////////////////////////////////////////////

public class PMovieRec implements Comparable<PMovieRec>
{

	/**
	 * PMovieRec parameters
	 */
	private String name;
	private int releaseYear;

	/**
	 * PMovieRec Constructor
	 * 
	 * @param name
	 * @param releaseyear
	 */
	public PMovieRec(String name, int releaseyear) {
		this.name = name;
		this.releaseYear = releaseyear;
	}

	/**
	 * Accessor method
	 * 
	 * @return String name
	 */
	public String getName() {
		return name;
	}

	/**
	 * Mutator method to set name to String name
	 * 
	 * @param String
	 *            name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Accessor method
	 * 
	 * @return int releaseyear
	 */
	public int getReleaseYear() {
		return releaseYear;
	}

	/**
	 * Mutator method to set release year to int releaseyear
	 * 
	 * @param releaseyear
	 */
	public void setReleaseYear(int releaseyear) {
		this.releaseYear = releaseyear;
	}

	/**
	 * Gets a String representation of this object.
	 * @return a String representation of this object.
	 */
	public String toString() {
		return "Name: " + name + "; Release Year: " + releaseYear;
	}
	
	/**
	 * Gets whether the given PMovieRec is equal to this one.
	 * @param otherMovie the other PMovieRec being compared to this PMovieRec.
	 * @return true if the two PMovieRecs are equal, false otherwise.
	 */
	public boolean equals(PMovieRec otherMovie)
	{
		if (name.equals(otherMovie.getName()))
			if (releaseYear == otherMovie.getReleaseYear())
				return true;
		return false;
	}
	
	/**
	 * Compares this PMovieRec to another movieRec.
	 * @param movieRec the other PMovieRec being compared to this one.
	 * @return -1 if this PMovieRec comes before movieRec, 0 if they are equal, and 1 if this PMovieRec comes after movieRec.
	 */
	public int compareTo(PMovieRec movieRec)
	{
		if (name.compareTo(movieRec.getName()) == 0)
		{
			if (releaseYear > movieRec.getReleaseYear())
				return 1;
			else if (releaseYear < movieRec.getReleaseYear())
				return -1;
			return 0;
		}
		else
			return name.compareTo(movieRec.getName());
	}
}
